<?php $this->renderPartial('../common/_header');?>
<div class="container my-container">
    <div class="row">
        <div class="col col-lg-3">
            <?php $this->renderPartial('//common/'.($this->user ? 'menu' : 'menu_guest'));?>
        </div>
        <div class="col col-lg-9">

            <div id="content-update">

                <div class="col col-lg-12">
                    <div class="page-header">
                        <h2>Hàng về</h2>
                    </div>
                        <a class="btn btn-primary btn-large require-login" href="<?php echo $this->createAbsoluteUrl('/hangve/post/create')?>">Đăng bài</a>
                </div>
            </div>
        </div>
    </div>

</div>



<div id="modal-login" class="modal fade" role="dialog" tabindex="-1" aria-hidden="true" aria-labelledby="myModalLabel" style="display: none;">
    <div class="modal-dialog">
        <div class="modal-content">

            <div class="modal-header">
                <button aria-hidden="true" data-dismiss="modal" class="close modal-login-close" type="button">×</button>
                <h4 id="myModalLabel" class="modal-title">Bạn cần đăng nhập để thực hiện chức năng này</h4>
            </div>
            <div class="modal-body">

                <div class="row">
                    <div class="col col-lg-6">
                        <?php $form=$this->beginWidget('CActiveForm', array(
                                'id'=>'login-form',
                                'action'=> $this->createUrl('/user/page/login'),
                                'enableClientValidation'=>true,
                                'clientOptions'=>array(
                                    'validateOnSubmit' => true,
                                    'validateOnChange' => true,
                                ),
                                'enableAjaxValidation'=>false,
                                'htmlOptions' => array('class' => 'form-horizontal my-form')
                            )); $loginForm = new LoginForm()?>

                        <div class="row">
                            <?php echo $form->labelEx($loginForm,'username', array('class' => 'col col-lg-4 control-label')); ?>
                            <div class="col col-lg-8">
                                <?php echo $form->textField($loginForm,'username',array('placeholder'=> $loginForm->getAttributeLabel('username'),'maxlength'=>255)); ?>
                                <?php echo $form->error($loginForm,'username');?>
                            </div>
                        </div> 

                        <div class="row">
                            <?php echo $form->labelEx($loginForm,'password', array('class' => 'col col-lg-4 control-label')); ?>
                            <div class="col col-lg-8">
                                <?php echo $form->passwordField($loginForm,'password',array('placeholder'=> $loginForm->getAttributeLabel('password'),'maxlength'=>255)); ?>
                                <?php echo $form->error($loginForm,'password');?>
                            </div>
                            <div class="col col-lg-8 col-offset-4 margintop15">
                                <button class="btn btn-primary" type="submit">
                                    <i class="icon-signin"></i> Đăng nhập
                                </button>                               
                            </div>
                            <div class="col col-lg-8 col-offset-4 margintop15 link-more">
                                <a href="<?php echo $this->createUrl('/user/page/create')?>" class="decoration-none" rel="tooltip" data-placement="top" title="Đăng ký tài khoản mới"><span class="label label-success">Đăng ký</span></a>
                                <a href="<?php echo $this->createUrl('/user/page/forgot')?>" class="decoration-none" rel="tooltip" data-placement="top" title="Bạn không nhớ mật khẩu của mình ?"><span class="label label-warning">Quên mật khẩu</span></a>
                            </div>
                        </div> 

                        <?php $this->endWidget(); ?>
                    </div>
                    <div class="col col-lg-6">
                        <div>Đăng nhập với</div>
                        <div class="my-openid large">
                            <a href="<?php echo $this->createUrl('/user/page/login', array('service' => 'facebook'))?>" title="" data-trigger="hover" data-placement="top" rel="popover" class="openid_popup decoration-none" data-original-title="Đăng nhập tài khoản Facebook">
                                <i class="icon-facebook-sign"></i>
                            </a>
                            &nbsp;
                            &nbsp;
                            <a href="<?php echo $this->createUrl('/user/page/login', array('service' => 'google'))?>" title="" data-trigger="hover" data-placement="top" rel="popover" class="openid_popup decoration-none" data-original-title="Đăng nhập bằng tài khoản Google">
                                <i class="icon-google-plus-sign"></i>
                            </a>
                        </div>
                    </div>
                </div>



            </div><!-- /.modal-content -->
            <div class="modal-footer">
                <button data-dismiss="modal" class="btn btn-default modal-login-close" type="button">Đóng</button>
            </div>
        </div><!-- /.modal-dalog -->
    </div>
</div>

<script>
        $('.require-login').click(function(e){
            e.preventDefault();
            $('#modal-login').modal();
            if($(this).attr('href') != undefined){
                $.cookie('loginRedirect', $(this).attr('href'));
            }
        });

        $('.modal-login-close').click(function () {
            $.cookie('loginRedirect', null);
        });

</script>